import { clearNoNum } from "@/utils/inupt";
import { goodsNameRend } from "@/utils/tableColumns";
import dayjs from "dayjs";

export function useColumns() {
  const kclsColumns: TableColumnList = [
    {
      type: "expand",
      slot: "expand",
      fixed: "left",
      width: "30px"
    },
    {
      label: "业务日期",
      prop: "storeCode",
      formatter: ({ gmtModified }) => dayjs(gmtModified).format("YYYY-MM-DD"),
      width: 150
    },
    {
      label: "商品名称/规格名称",
      prop: "goodsName",
      width: 200,
      align: "left",
      showOverflowTooltip: true,
      cellRenderer: goodsNameRend
    },
    {
      label: "业务类型",
      prop: "storeCode",
      formatter: ({ gmtModified }) => dayjs(gmtModified).format("YYYY-MM-DD"),
      width: 150
    },
    {
      label: "业务单据编号",
      prop: "storeCode",
      formatter: ({ gmtModified }) => dayjs(gmtModified).format("YYYY-MM-DD"),
      width: 150
    },
    {
      label: "仓库名称",
      prop: "barCode",
      width: 150,
      slot: "barCode"
    },
    {
      label: "入库商品数量",
      prop: "rksl",
      width: 160,
      cellRenderer: ({ row }) => (
        <el-input
          v-show={row.goodsSpecList && row.goodsSpecList.length == 1}
          v-model={row.rksl}
          placeholder="请输入"
          clearable
          onInput={$event => (row.rksl = clearNoNum($event))}
        />
      )
    },
    {
      label: "供应商名称",
      prop: "supplierName",
      showOverflowTooltip: true,
      minWidth: 120
    }
  ];

  const ggkcColumns: TableColumnList = [
    {
      label: "商品名称/规格名称",
      prop: "specName",
      minWidth: 200,
      align: "left",
      cellRenderer: goodsNameRend
    },
    {
      label: "仓库名称",
      prop: "depositoryName",
      minWidth: 150,
      formatter: ({ depositoryName }) => depositoryName || "--"
    },
    {
      label: "实际库存",
      prop: "actualNum",
      minWidth: 120
    },
    {
      label: "可用库存",
      prop: "canUseNum",
      minWidth: 120
    },
    {
      label: "在途库存",
      prop: "sendNum",
      minWidth: 120
    }
  ];

  return {
    kclsColumns,
    ggkcColumns
  };
}
